#include "power.h"
#include <Arduino.h>

int powerPin = 4;   // select the input pin for the potentiometer
int powerPinState = 0;  // variable to store the value coming from the sensor

void PowerInit(void)
{
  pinMode(powerPin, OUTPUT);
  digitalWrite(powerPin, HIGH);
}

void PowerTask(u32 tick)
{
  if ((tick % 10000) == 0) {
    powerPinState = 1;
  }
  if (powerPinState > 0) {
      if (powerPinState == 1) {
        digitalWrite(powerPin, LOW);
        Serial.printf("state%d...\n", digitalRead(powerPin));
    } else if (powerPinState > 100) {
        digitalWrite(powerPin, HIGH);
        powerPinState = 0;
        Serial.printf("state%d...\n", digitalRead(powerPin));
        return;
    }
    powerPinState++;
  }
}